<template>
	<view class="bg_fff W_100vw H_100vh">
		
		<view class="flex_rowC" style="padding-top: 10vh;">
			<image class="W_40vw" src="../../static/login_logo.png" mode="widthFix"></image>
		</view>
		
		<view class="PTB_2 PLR_4 PT_10">
			<!-- <view class="pub_color font_weight_bold fontS_22">
				欢迎登陆
			</view> -->
			<!-- <view class="fontS_10 PT_4 PB_2">
				手机号
			</view> -->
			<view class="MLR_8 PTB_2 B_radius_5 flex_rowL line_bom">
				<image class="W_4vw MLR_3" src="../../static/mobile.png" mode="widthFix"></image>
				<input class="PL_5" v-model="mobile" type="text" placeholder="请输入手机号" />
			</view>
			<view class="MLR_8 PTB_2 B_radius_5 flex_rowL line_bom">
				<image class="W_4vw MLR_3" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_5" v-model="pass" type="password" placeholder="请输入登录密码" />
			</view>
			
			<view class="flex_row_between color_gray MLR_8 fontS_10 PT_3">
				<view @click="uOpenWin('./register')" class="">
					注册
				</view>
				<view @click="uOpenWin('./forget')" class="">
					忘记密码
				</view>
			</view>
			
			<view @click="login()" class="pub_btn B_radius_max MT_6 PTB_2 MLR_8">
				登录
			</view>
			
			
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile:'',
				pass:'',
			}
		},
		onLoad() {
			var token = uni.getStorageSync('token')
			console.log(token)
			if(token){
				uni.switchTab({
					url:'../index/index'
				})
			}
		},
		methods: {
			login(){
				let _this = this;
				if(!this.mobile){
					this.toast('请输入登录名')
				}else{
					this.$req('auth/login',
					{mobile:_this.mobile,password:_this.pass},(res)=>{
						if(res.code==1){
							_this.toast('登录成功');
							uni.setStorage({
								key:'token',
								data:res.data.token
							});
							setTimeout(()=>{
								uni.switchTab({
									url:'../index/index'
								})
							},500)
							
						}else{
							_this.toast(res.data)
						}
					})
				}
			}
		}
	}
</script>

<style>
.login_bg{
	background-image: url(../../static/login_bg.png);
	background-repeat: no-repeat;
	background-size: 100% 100%;
}
</style>
